#{extends 'layout/main.html' /}
#{set title:'Test upload !!!' /}

<link rel="stylesheet" href="/public/javascripts/plugins/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" />
<script type="text/javascript" src="/public/javascripts/plugins/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>


<script type="text/javascript" src="/public/javascripts/plugins/plupload/plupload.js"></script>
<script type="text/javascript" src="/public/javascripts/plugins/plupload/plupload.html5.js"></script>

<script>

$(function(){
	$("#uploader").pluploadQueue({
	      // General settings
	      runtimes : 'html5',
	      url : '/utility/upload?type=csv&t=${time}',
	      max_file_size : '10mb',
	      chunk_size : '1mb',
	      unique_names : true,

	      // Resize images on clientside if we can
	      resize : {width : 320, height : 240, quality : 90},

	      // Specify what files to browse for
	      filters : [
	          {title : "Image files", extensions : "jpg,gif,png"},
	          {title : "Zip files", extensions : "zip"}
	      ],
	});
	
	var uploader = $("#uploader").pluploadQueue();
	
	uploader.bind('UploadComplete', function(up, file) {
		alert("Upload complete");
	});
});
	
	function upload_success(){
		var option = {
	       type: 'POST',
	       url: '@{utility.finishUpload()}?t=${time}',
	       dataType: 'json',
	       success: function(response){
	       	if(response.status == "success")
	       	{
	       		alert("Upload successfully!");
	       	}
	       	else
	       	{
	       		alert("Upload failure. Please try again!");
	       	}
	       },
	       error: function(XMLHttpRequest, textStatus, errorThrown) {
	       	
	       }
	   };
	   
	   $.ajax(option);
	}
</script>

Upload
<div id="uploader"></div>
<hr/>

<div>
	<button onclick="upload_click();">Upload</button>
</div>


